<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>给定字符串，实现首字母大写，其他部分小写</title>
</head>
<body>
  <script>
    function firstUpperCase(str) {
      let arr = str.toUpperCase().split(' ')
      for(let i = 0; i < arr.length; i++) {
        arr[i] = arr[i].charAt(0) + arr[i].slice(1).toLowerCase()
      }
      return arr.join(' ')
    }
    console.log(firstUpperCase('asd dfsdf sgsd sdfdf'))
  </script>
</body>
</html>